<template>
  <el-row>
    <span>搜索</span>
    <span class="search_text">{{ searchText }}</span>
    <span>的资源，共有</span>
    <span class="search_text">{{ num }}</span>
    <span>条结果，用时</span>
    <span class="search_text">{{ time }}</span>
    <span>秒</span>
    <label class="label">每页显示:</label>
    <el-select style="width: 130px;" v-model="pageSize" placeholder="请选择">
      <el-option
        v-for="item in options"
        :key="'pageSize' + item.value"
        :label="item.label"
        :value="item.value"
      ></el-option>
    </el-select>
    <label class="label">显示方式:</label>
    <el-select style="width: 130px;" v-model="showType" placeholder="请选择">
      <el-option
        v-for="item in typeOptions"
        :key="'typeOptions' + item.value"
        :label="item.label"
        :value="item.value"
      ></el-option>
    </el-select>
    <label class="label">排序方式:</label>
    <el-select style="width: 130px;" v-model="sort" placeholder="请选择">
      <el-option
        v-for="item in sortOptions"
        :key="'sortOptions' + item.value"
        :label="item.label"
        :value="item.value"
      ></el-option>
    </el-select>
  </el-row>
</template>

<script>
  export default {
    name: 'TopSearch',
    props: {
      searchText: {
        type: String,
        default: ''
      },
      num: {
        type: Number,
        default: 0
      },
      time: {
        type: String,
        default: ''
      }
    },
    computed: {
      parmas() {
        return {
          pageSize: this.pageSize,
          showType: this.showType,
          sort: this.sort
        }
      }
    },
    watch: {
      parmas: {
        handler: function(val, oldVal) {
          this.$emit('paramsChange', val)
        },
        immediate: true,
        deep: true
      }
    },
    data() {
      return {
        pageSize: 10,
        showType: 1,
        sort: 1,
        options: [
          { value: 10, label: '10条' },
          { value: 20, label: '20条' },
          { value: 50, label: '50条' }
        ],
        typeOptions: [
          { value: 1, label: '粗略显示' },
          { value: 2, label: '详细显示' }
        ],
        sortOptions: [
          { value: 1, label: '默认排序' },
          { value: 2, label: '正序' },
          { value: 4, label: '反序' }
        ]
      }
    },
    methods: {}
  }
</script>

<style lang="scss" scoped>
  .search_text {
    padding-left: 10px;
    padding-right: 10px;
    color: #ea3f3f;
  }

  .label {
    margin-left: 19px;
    margin-right: 6px;
  }
</style>
